<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.4.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">
  <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/pace/1.0.2/themes/blue/pace-theme-minimal.min.css">
  <script src="//cdnjs.cloudflare.com/ajax/libs/pace/1.0.2/pace.min.js"></script>

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"zhangyh.fun","root":"/","scheme":"Pisces","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":true,"show_result":true,"style":"default"},"back2top":{"enable":true,"sidebar":false,"scrollpercent":true},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.xml"};
  </script>

  <meta name="description" content="Hexo 搭建个人博客">
<meta property="og:type" content="article">
<meta property="og:title" content="Hexo 搭建个人博客">
<meta property="og:url" content="https://zhangyh.fun/2021/08/13/Hexo%20%E6%90%AD%E5%BB%BA%E4%B8%AA%E4%BA%BA%E5%8D%9A%E5%AE%A2/index.html">
<meta property="og:site_name" content="XiaoPang の Blog">
<meta property="og:description" content="Hexo 搭建个人博客">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2021-08-13T02:40:00.000Z">
<meta property="article:modified_time" content="2021-08-20T09:36:43.043Z">
<meta property="article:author" content="XiaoPang">
<meta property="article:tag" content="hexo">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="https://zhangyh.fun/2021/08/13/Hexo%20%E6%90%AD%E5%BB%BA%E4%B8%AA%E4%BA%BA%E5%8D%9A%E5%AE%A2/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>Hexo 搭建个人博客 | XiaoPang の Blog</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

  <script>
  var _hmt = _hmt || [];
  (function() {
    var hm = document.createElement("script");
    hm.src = "https://hm.baidu.com/hm.js?54b35e78bac318b678b24fbb33049203";
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(hm, s);
  })();
  </script>


</head>

<body itemscope itemtype="http://schema.org/WebPage">

  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">XiaoPang の Blog</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
    <script src="https://v1.hitokoto.cn/?c=f&encode=js&select=%23hitokoto" defer></script>

      <p class="site-subtitle" itemprop="description" id="hitokoto"><span id="hitokoto_text">记录生活中的点点滴滴</span></p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-about">

    <a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签<span class="badge">19</span></a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类<span class="badge">11</span></a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档<span class="badge">34</span></a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result">
  <div id="no-result">
    <i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
  </div>
</div>

    </div>
  </div>

</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <script src="//cdn.bootcss.com/clipboard.js/1.5.10/clipboard.min.js"></script>
  <!-- JS库 sweetalert 可修改路径 -->
  <script src="https://cdn.bootcss.com/jquery/2.0.0/jquery.min.js"></script>
  <script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://zhangyh.fun/2021/08/13/Hexo%20%E6%90%AD%E5%BB%BA%E4%B8%AA%E4%BA%BA%E5%8D%9A%E5%AE%A2/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="XiaoPang">
      <meta itemprop="description" content="少说，多做">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="XiaoPang の Blog">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          Hexo 搭建个人博客
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于：</span>

              <time title="创建时间：2021-08-13 10:40:00" itemprop="dateCreated datePublished" datetime="2021-08-13T10:40:00+08:00">2021-08-13</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于：</span>
                <time title="修改时间：2021-08-20 17:36:43" itemprop="dateModified" datetime="2021-08-20T17:36:43+08:00">2021-08-20</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Hexo/" itemprop="url" rel="index"><span itemprop="name">Hexo</span></a>
                </span>
            </span>

          
            <span class="post-meta-item" title="阅读次数" id="busuanzi_container_page_pv" style="display: none;">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
              <span id="busuanzi_value_page_pv"></span>
            </span>
            <br>
            <span class="post-meta-item" title="本文字数">
            <span class="post-meta-item-icon">
            <i class="fa fa-file-word"></i>
            </span>
           <span class="post-meta-item-text">本文字数：</span>
           <span title="post.wordcount">
                2.2k 字
            </span>
            </span>
            <span class="post-meta-item" title="阅读时长">
            <span class="post-meta-item-icon">
            <i class="fa fa-clock"></i>
            </span>
          <span class="post-meta-item-text">阅读时长：</span>
           <span title="post.min2read">
                11 分钟
            </span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <p><strong>Hexo 搭建个人博客</strong></p>
<span id="more"></span>
<h2 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h2><ul>
<li><code>Hexo</code> 是一个快速、简洁且高效的博客框架。<code>Hexo</code> 使用 <code>Markdown</code> 或其他渲染引擎解析文章，可利用靓丽的主题生成静态网页。</li>
</ul>
<h2 id="安装并使用"><a href="#安装并使用" class="headerlink" title="安装并使用"></a>安装并使用</h2><ul>
<li>注：安装之前确保已经安装好<code>node.js</code><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"># 1. 设置npm源（已经设置过，忽略这一步）</span><br><span class="line">npm config set registry https://registry.npm.taobao.org</span><br><span class="line"># 2. 安装hexo-cli</span><br><span class="line">npm install -g hexo-cli</span><br><span class="line"># 3. 创建博客项目</span><br><span class="line">hexo init blog(博客项目名)</span><br><span class="line"># 4. 生成第一篇文章</span><br><span class="line">hexo new my_one_blog</span><br><span class="line"># 博客文件目录</span><br><span class="line">&#123;博客项目目录&#125;\blog\source\_posts</span><br><span class="line"># 5. 启动hexo 服务</span><br><span class="line">hexo server</span><br><span class="line"># 本地访问博客网站（http://127.0.0.1:4000）</span><br><span class="line"># 博客打包，生成HTML/CSS/JS文件</span><br><span class="line">hexo generate</span><br><span class="line"># 文件目录: &#123;博客项目目录&#125;\blog\public</span><br></pre></td></tr></table></figure></li>
</ul>
<h2 id="博客页面操作"><a href="#博客页面操作" class="headerlink" title="博客页面操作"></a>博客页面操作</h2><h3 id="博客主题更换"><a href="#博客主题更换" class="headerlink" title="博客主题更换"></a>博客主题更换</h3><blockquote>
<p>主题地址：<code>https://hexo.io/themes/</code><br>本文选择：<code>https://github.com/theme-next/hexo-theme-next</code></p>
</blockquote>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"># 第一种：使用git 提交命令，将代码提交到github（不建议推荐）</span><br><span class="line"># 1. 目录切换到博客项目根目录</span><br><span class="line"># 2. github 远程存储库克隆到本地存储库</span><br><span class="line">git clone https://github.com/theme-next/hexo-theme-next themes/next</span><br><span class="line"># 3. 标签版本切换</span><br><span class="line">cd themes/next</span><br><span class="line"># 3.1 查看标签版本</span><br><span class="line">git tag -l</span><br><span class="line"># 3.2 切换分支</span><br><span class="line">git checkout tags/v5.1.0</span><br><span class="line">git checkout master</span><br><span class="line"># 4. 设置使用主题</span><br><span class="line"># 修改项目根目录下的 _config.yml</span><br><span class="line">theme: next</span><br></pre></td></tr></table></figure>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><span class="line"># 第二种：使用hexo 命令</span><br><span class="line"># 1. 修改博客项目目录下 _config.yml</span><br><span class="line">deploy:</span><br><span class="line">  type: git</span><br><span class="line">  repository: https://github.com/zhang123-123/zhang123-123.github.io.git</span><br><span class="line">  branch: master</span><br><span class="line">  (分支名与在github page设置一样)</span><br><span class="line"># 2. 执行命令</span><br><span class="line">hexo g -d</span><br><span class="line"># 如果命令执行报错，说明deployer 没有安装成功</span><br><span class="line">  ERROR Deployer not found: git</span><br><span class="line"># 3. 执行安装命令（如果上一条命令执行未报错，忽略这一步）</span><br><span class="line">npm install hexo-deployer-git --save</span><br><span class="line"># 4. 重新执行命令</span><br><span class="line">hexo g -d</span><br><span class="line"># 5. 选择主题，目录切换到themes</span><br><span class="line">cd themes</span><br><span class="line"># 6. github 远程存储库克隆到本地存储库</span><br><span class="line">git clone https://github.com/theme-next/hexo-theme-next</span><br><span class="line"># 7. 设置使用主题</span><br><span class="line"># 修改项目根目录下的 _config.yml</span><br><span class="line">theme: hexo-theme-next</span><br><span class="line"># 8. 清除缓存，若不输入此命令，服务器有可能更新不了主题</span><br><span class="line">hexo clean</span><br><span class="line"># 9. 重新执行命令</span><br><span class="line">hexo g -d</span><br></pre></td></tr></table></figure>

<h2 id="Hexo-博客UI-优化（next-主题）"><a href="#Hexo-博客UI-优化（next-主题）" class="headerlink" title="Hexo 博客UI 优化（next 主题）"></a>Hexo 博客UI 优化（next 主题）</h2><h3 id="UI-界面中文化"><a href="#UI-界面中文化" class="headerlink" title="UI 界面中文化"></a>UI 界面中文化</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"># 修改项目根目录下的 _config.yml，查看&#123;博客根目录&#125;\themes\hexo-theme-next\language对应文件</span><br><span class="line">language: zh-CN</span><br></pre></td></tr></table></figure>
<h3 id="添加博客统计信息（字数统计-阅读时长）"><a href="#添加博客统计信息（字数统计-阅读时长）" class="headerlink" title="添加博客统计信息（字数统计/阅读时长）"></a>添加博客统计信息（字数统计/阅读时长）</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br></pre></td><td class="code"><pre><span class="line"># 使用插件</span><br><span class="line">hexo-wordcount</span><br><span class="line"># 修改配置文件，next主题目录下的 _config.yml</span><br><span class="line"># 统计字数和阅读时长</span><br><span class="line">post_wordcount:</span><br><span class="line">  item_text: true</span><br><span class="line">  wordcount: true         # 单篇 字数统计</span><br><span class="line">  min2read: true          # 单篇 阅读时长</span><br><span class="line">  totalcount: false       # 网站 字数统计</span><br><span class="line">  separated_meta: true</span><br><span class="line"># 添加页面显示信息</span><br><span class="line"># &#123;博客根目录&#125;\themes\hexo-theme-next\layout\post.swig</span><br><span class="line">&#123;%- if theme.post_wordcount.item_text %&#125;  </span><br><span class="line">  &lt;br&gt;  </span><br><span class="line">  &lt;span class=&quot;post-meta-item&quot; title=&quot;&#123;&#123; __(&#x27;symbols_count_time.count&#x27;) &#125;&#125;&quot;&gt;  </span><br><span class="line">  &lt;span class=&quot;post-meta-item-icon&quot;&gt;  </span><br><span class="line">  &lt;i class=&quot;fa fa-file-word&quot;&gt;&lt;/i&gt;  </span><br><span class="line">  &lt;/span&gt;  </span><br><span class="line"> &lt;span class=&quot;post-meta-item-text&quot;&gt;&#123;&#123; __(&#x27;symbols_count_time.count&#x27;) &#125;&#125;：&lt;/span&gt;  </span><br><span class="line"> &lt;span title=&quot;&#123;&#123; __(&#x27;post.wordcount&#x27;) &#125;&#125;&quot;&gt;  </span><br><span class="line">      &#123;&#123; wordcount(post.content) &#125;&#125; 字  </span><br><span class="line">  &lt;/span&gt;  </span><br><span class="line">  &lt;/span&gt;  </span><br><span class="line">  &lt;span class=&quot;post-meta-item&quot; title=&quot;&#123;&#123; __(&#x27;symbols_count_time.time&#x27;) &#125;&#125;&quot;&gt;  </span><br><span class="line">  &lt;span class=&quot;post-meta-item-icon&quot;&gt;  </span><br><span class="line">  &lt;i class=&quot;fa fa-clock&quot;&gt;&lt;/i&gt;  </span><br><span class="line">  &lt;/span&gt;  </span><br><span class="line">&lt;span class=&quot;post-meta-item-text&quot;&gt;&#123;&#123; __(&#x27;symbols_count_time.time&#x27;) &#125;&#125;：&lt;/span&gt;  </span><br><span class="line"> &lt;span title=&quot;&#123;&#123; __(&#x27;post.min2read&#x27;) &#125;&#125;&quot;&gt;  </span><br><span class="line">      &#123;&#123; min2read(post.content) &#125;&#125; 分钟  </span><br><span class="line">  &lt;/span&gt;  </span><br><span class="line">  &lt;/span&gt;  </span><br><span class="line"> &#123;%- endif%&#125;</span><br></pre></td></tr></table></figure>
<h3 id="添加鼠标点击♥显示"><a href="#添加鼠标点击♥显示" class="headerlink" title="添加鼠标点击♥显示"></a>添加鼠标点击♥显示</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"># 1. 创建js 文件（path: &#123;博客根目录&#125;\themes\hexo-theme-next\source\js\my_js\clicklove.js）</span><br><span class="line">!function(e,t,a)&#123;function n()&#123;c(&quot;.heart&#123;width: 10px;height: 10px;position: fixed;background: #f00;transform: rotate(45deg);-webkit-transform: rotate(45deg);-moz-transform: rotate(45deg);&#125;.heart:after,.heart:before&#123;content: &#x27;&#x27;;width: inherit;height: inherit;background: inherit;border-radius: 50%;-webkit-border-radius: 50%;-moz-border-radius: 50%;position: fixed;&#125;.heart:after&#123;top: -5px;&#125;.heart:before&#123;left: -5px;&#125;&quot;),o(),r()&#125;function r()&#123;for(var e=0;e&lt;d.length;e++)d[e].alpha&lt;=0?(t.body.removeChild(d[e].el),d.splice(e,1)):(d[e].y--,d[e].scale+=.004,d[e].alpha-=.013,d[e].el.style.cssText=&quot;left:&quot;+d[e].x+&quot;px;top:&quot;+d[e].y+&quot;px;opacity:&quot;+d[e].alpha+&quot;;transform:scale(&quot;+d[e].scale+&quot;,&quot;+d[e].scale+&quot;) rotate(45deg);background:&quot;+d[e].color+&quot;;z-index:99999&quot;);requestAnimationFrame(r)&#125;function o()&#123;var t=&quot;function&quot;==typeof e.onclick&amp;&amp;e.onclick;e.onclick=function(e)&#123;t&amp;&amp;t(),i(e)&#125;&#125;function i(e)&#123;var a=t.createElement(&quot;div&quot;);a.className=&quot;heart&quot;,d.push(&#123;el:a,x:e.clientX-5,y:e.clientY-5,scale:1,alpha:1,color:s()&#125;),t.body.appendChild(a)&#125;function c(e)&#123;var a=t.createElement(&quot;style&quot;);a.type=&quot;text/css&quot;;try&#123;a.appendChild(t.createTextNode(e))&#125;catch(t)&#123;a.styleSheet.cssText=e&#125;t.getElementsByTagName(&quot;head&quot;)[0].appendChild(a)&#125;function s()&#123;return&quot;rgb(&quot;+~~(255*Math.random())+&quot;,&quot;+~~(255*Math.random())+&quot;,&quot;+~~(255*Math.random())+&quot;)&quot;&#125;var d=[];e.requestAnimationFrame=function()&#123;return e.requestAnimationFrame||e.webkitRequestAnimationFrame||e.mozRequestAnimationFrame||e.oRequestAnimationFrame||e.msRequestAnimationFrame||function(e)&#123;setTimeout(e,1e3/60)&#125;&#125;(),n()&#125;(window,document);</span><br><span class="line"></span><br><span class="line"># 2. 调用js文件（path:  &#123;博客根目录&#125;\themes\hexo-theme-next\layout\_layout.swig）</span><br><span class="line">&lt;!-- 页面点击小红心 --&gt;  </span><br><span class="line">&lt;script type=&quot;text/javascript&quot; src=&quot;/js/clicklove.js&quot;&gt;&lt;/script&gt;</span><br><span class="line"># 3. 重启服务</span><br><span class="line">hexo server</span><br></pre></td></tr></table></figure>
<h3 id="页面背景动态线条配置"><a href="#页面背景动态线条配置" class="headerlink" title="页面背景动态线条配置"></a>页面背景动态线条配置</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"># 1. 创建js 文件（path: &#123;博客根目录&#125;\themes\hexo-theme-next\source\js\my_js\clicklove.js）</span><br><span class="line">// 背景动态线条js  </span><br><span class="line">!function()&#123;function o(w,v,i)&#123;return w.getAttribute(v)||i&#125;function j(i)&#123;return document.getElementsByTagName(i)&#125;function l()&#123;var i=j(&quot;script&quot;),w=i.length,v=i[w-1];return&#123;l:w,z:o(v,&quot;zIndex&quot;,-1),o:o(v,&quot;opacity&quot;,0.5),c:o(v,&quot;color&quot;,&quot;0,0,0&quot;),n:o(v,&quot;count&quot;,99)&#125;&#125;function k()&#123;r=u.width=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,n=u.height=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight&#125;function b()&#123;e.clearRect(0,0,r,n);var w=[f].concat(t);var x,v,A,B,z,y;t.forEach(function(i)&#123;i.x+=i.xa,i.y+=i.ya,i.xa*=i.x&gt;r||i.x&lt;0?-1:1,i.ya*=i.y&gt;n||i.y&lt;0?-1:1,e.fillRect(i.x-0.5,i.y-0.5,1,1);for(v=0;v&lt;w.length;v++)&#123;x=w[v];if(i!==x&amp;&amp;null!==x.x&amp;&amp;null!==x.y)&#123;B=i.x-x.x,z=i.y-x.y,y=B*B+z*z;y&lt;x.max&amp;&amp;(x===f&amp;&amp;y&gt;=x.max/2&amp;&amp;(i.x-=0.03*B,i.y-=0.03*z),A=(x.max-y)/x.max,e.beginPath(),e.lineWidth=A/2,e.strokeStyle=&quot;rgba(&quot;+s.c+&quot;,&quot;+(A+0.2)+&quot;)&quot;,e.moveTo(i.x,i.y),e.lineTo(x.x,x.y),e.stroke())&#125;&#125;w.splice(w.indexOf(i),1)&#125;),m(b)&#125;var u=document.createElement(&quot;canvas&quot;),s=l(),c=&quot;c_n&quot;+s.l,e=u.getContext(&quot;2d&quot;),r,n,m=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(i)&#123;window.setTimeout(i,1000/45)&#125;,a=Math.random,f=&#123;x:null,y:null,max:20000&#125;;u.id=c;u.style.cssText=&quot;position:fixed;top:0;left:0;z-index:&quot;+s.z+&quot;;opacity:&quot;+s.o;j(&quot;body&quot;)[0].appendChild(u);k(),window.onresize=k;window.onmousemove=function(i)&#123;i=i||window.event,f.x=i.clientX,f.y=i.clientY&#125;,window.onmouseout=function()&#123;f.x=null,f.y=null&#125;;for(var t=[],p=0;s.n&gt;p;p++)&#123;var h=a()*r,g=a()*n,q=2*a()-1,d=2*a()-1;t.push(&#123;x:h,y:g,xa:q,ya:d,max:6000&#125;)&#125;setTimeout(function()&#123;b()&#125;,100)&#125;();</span><br><span class="line"></span><br><span class="line"># 2. 主题根目录配置_config.yml</span><br><span class="line">canvas_nest: true</span><br><span class="line"># 3. 调用js 文件（注意：代码body标签内部）</span><br><span class="line">&#123;% if theme.canvas_nest %&#125;  </span><br><span class="line">  &lt;script type=&quot;text/javascript&quot; color=&quot;0,0,0&quot; opacity=&#x27;0.5&#x27; zIndex=&quot;-2&quot; count=&quot;200&quot; src=&quot;/js/my_js/canvas-nest.min.js&quot;&gt;&lt;/script&gt;  </span><br><span class="line">  &#123;% endif %&#125;</span><br><span class="line">&quot;&quot;&quot;</span><br><span class="line">-   color：表示线条颜色，三个数字分别为(R,G,B)，默认：（0,0,0）</span><br><span class="line">-   opacity：表示线条透明度（0~1），默认：0.5</span><br><span class="line">-   count：表示线条的总数量，默认：150</span><br><span class="line">-   zIndex：表示背景的z-index属性，css属性用于控制所在层的位置，默认：-1</span><br><span class="line">&quot;&quot;&quot;</span><br></pre></td></tr></table></figure>
<h3 id="页面主题动态显示-subtitle"><a href="#页面主题动态显示-subtitle" class="headerlink" title="页面主题动态显示 subtitle"></a>页面主题动态显示 subtitle</h3><ul>
<li><code>path</code>: <code>&#123;hexo根目录&#125;\themes\hexo-theme-next\layout\_partials\header\brand.swig</code><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">&#123;%- if subtitle %&#125;  </span><br><span class="line">&lt;script src=&quot;https://v1.hitokoto.cn/?c=f&amp;encode=js&amp;select=%23hitokoto&quot; defer&gt;&lt;/script&gt;  </span><br><span class="line">  </span><br><span class="line">  &lt;p class=&quot;site-subtitle&quot; itemprop=&quot;description&quot; id=&quot;hitokoto&quot;&gt;&lt;span id=&quot;hitokoto_text&quot;&gt;&#123;&#123; subtitle &#125;&#125;&lt;/span&gt;&lt;/p&gt;  </span><br><span class="line">&#123;%- endif %&#125;</span><br></pre></td></tr></table></figure></li>
</ul>
<h3 id="hexo-文章添加-图片"><a href="#hexo-文章添加-图片" class="headerlink" title="hexo 文章添加 图片"></a>hexo 文章添加 图片</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"># 1.修改配置文件。&#123;hexo根目录&#125;/_config.yml</span><br><span class="line">post_asset_folder: true (默认是false)</span><br><span class="line"># 2.下载插件</span><br><span class="line">npm install hexo-asset-image --save</span><br><span class="line"># 3.使用</span><br><span class="line"># 第一种：使用hexo 命令创建博客文章</span><br><span class="line">hexo n 博客名</span><br><span class="line"># 默认会在/source/_posts 目录下创建xxx.md和同名的文件夹</span><br><span class="line"># 图片存放在文件夹中</span><br><span class="line"># 在xxx.md 引用图片</span><br><span class="line">![你想输入的替代文字](图片名.jpg)</span><br><span class="line"># 第二种：直接创建xxx.md 和同名的文件夹</span><br><span class="line"># 引用方式与第一种一样。</span><br></pre></td></tr></table></figure>

    </div>

    
    
    
        

<div>
<ul class="post-copyright">
  <li class="post-copyright-author">
    <strong>本文作者： </strong>XiaoPang
  </li>
  <li class="post-copyright-link">
    <strong>本文链接：</strong>
    <a href="https://zhangyh.fun/2021/08/13/Hexo%20%E6%90%AD%E5%BB%BA%E4%B8%AA%E4%BA%BA%E5%8D%9A%E5%AE%A2/" title="Hexo 搭建个人博客">https://zhangyh.fun/2021/08/13/Hexo 搭建个人博客/</a>
    <span class="copy-path"  title="点击复制文章链接"><i class="fa fa-clipboard" data-clipboard-text="https://zhangyh.fun/2021/08/13/Hexo%20%E6%90%AD%E5%BB%BA%E4%B8%AA%E4%BA%BA%E5%8D%9A%E5%AE%A2/"  aria-label="复制成功！"></i></span>
  </li>
  <li class="post-copyright-license">
    <strong>版权声明： </strong>本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh" rel="noopener" target="_blank"><i class="fab fa-fw fa-creative-commons"></i>BY-NC-SA</a> 许可协议。转载请注明出处！
  </li>
</ul>
</div>
<script>
    var clipboard = new Clipboard('.fa-clipboard');
      $(".fa-clipboard").click(function(){
      clipboard.on('success', function(){
        swal({
          title: "",
          text: '复制成功',
          icon: "success",
          showConfirmButton: true
          });
        });
    });
</script>


      <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/hexo/" rel="tag"><i class="fa fa-tag"></i> hexo</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2021/08/13/Docker/" rel="prev" title="Docker 教程">
      <i class="fa fa-chevron-left"></i> Docker 教程
    </a></div>
      <div class="post-nav-item">
    <a href="/2021/08/13/Python%20%E4%B8%BB%E5%8A%A8%E6%8A%9B%E5%87%BA%E5%BC%82%E5%B8%B8%E5%92%8C%E8%87%AA%E5%AE%9A%E4%B9%89%E5%BC%82%E5%B8%B8/" rel="next" title="Python 主动抛出异常、自定义异常">
      Python 主动抛出异常、自定义异常 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    

  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%89%8D%E8%A8%80"><span class="nav-number">1.</span> <span class="nav-text">前言</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%AE%89%E8%A3%85%E5%B9%B6%E4%BD%BF%E7%94%A8"><span class="nav-number">2.</span> <span class="nav-text">安装并使用</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%8D%9A%E5%AE%A2%E9%A1%B5%E9%9D%A2%E6%93%8D%E4%BD%9C"><span class="nav-number">3.</span> <span class="nav-text">博客页面操作</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%8D%9A%E5%AE%A2%E4%B8%BB%E9%A2%98%E6%9B%B4%E6%8D%A2"><span class="nav-number">3.1.</span> <span class="nav-text">博客主题更换</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Hexo-%E5%8D%9A%E5%AE%A2UI-%E4%BC%98%E5%8C%96%EF%BC%88next-%E4%B8%BB%E9%A2%98%EF%BC%89"><span class="nav-number">4.</span> <span class="nav-text">Hexo 博客UI 优化（next 主题）</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#UI-%E7%95%8C%E9%9D%A2%E4%B8%AD%E6%96%87%E5%8C%96"><span class="nav-number">4.1.</span> <span class="nav-text">UI 界面中文化</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%B7%BB%E5%8A%A0%E5%8D%9A%E5%AE%A2%E7%BB%9F%E8%AE%A1%E4%BF%A1%E6%81%AF%EF%BC%88%E5%AD%97%E6%95%B0%E7%BB%9F%E8%AE%A1-%E9%98%85%E8%AF%BB%E6%97%B6%E9%95%BF%EF%BC%89"><span class="nav-number">4.2.</span> <span class="nav-text">添加博客统计信息（字数统计&#x2F;阅读时长）</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%B7%BB%E5%8A%A0%E9%BC%A0%E6%A0%87%E7%82%B9%E5%87%BB%E2%99%A5%E6%98%BE%E7%A4%BA"><span class="nav-number">4.3.</span> <span class="nav-text">添加鼠标点击♥显示</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E9%A1%B5%E9%9D%A2%E8%83%8C%E6%99%AF%E5%8A%A8%E6%80%81%E7%BA%BF%E6%9D%A1%E9%85%8D%E7%BD%AE"><span class="nav-number">4.4.</span> <span class="nav-text">页面背景动态线条配置</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E9%A1%B5%E9%9D%A2%E4%B8%BB%E9%A2%98%E5%8A%A8%E6%80%81%E6%98%BE%E7%A4%BA-subtitle"><span class="nav-number">4.5.</span> <span class="nav-text">页面主题动态显示 subtitle</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#hexo-%E6%96%87%E7%AB%A0%E6%B7%BB%E5%8A%A0-%E5%9B%BE%E7%89%87"><span class="nav-number">4.6.</span> <span class="nav-text">hexo 文章添加 图片</span></a></li></ol></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="XiaoPang"
      src="/images/avatar.gif">
  <p class="site-author-name" itemprop="name">XiaoPang</p>
  <div class="site-description" itemprop="description">少说，多做</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">34</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">11</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">19</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <a href="https://github.com/zhang123-123" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;zhang123-123" rel="noopener" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
      <span class="links-of-author-item">
        <a href="/1741290057@qq.com" title="E-Mail → 1741290057@qq.com"><i class="fa fa-envelope fa-fw"></i>E-Mail</a>
      </span>
  </div>
  <div class="cc-license motion-element" itemprop="license">
    <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh" class="cc-opacity" rel="noopener" target="_blank"><img src="/images/cc-by-nc-sa.svg" alt="Creative Commons"></a>
  </div>


<!-- CloudCalendar -->
<div class="widget-wrap" style="width: 90%;margin-left: auto;margin-right: auto; opacity: 0.97;">
	<div class="widget" id="CloudCalendar"></div>
</div>
      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2021</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">XiaoPang</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://pisces.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Pisces</a> 强力驱动
  </div>

        
<div class="busuanzi-count">
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    <span class="post-meta-item" id="busuanzi_container_site_uv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-user"></i>
      </span>
      <span class="site-uv" title="总访客量">
        <span id="busuanzi_value_site_uv"></span>
      </span>
    </span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item" id="busuanzi_container_site_pv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-eye"></i>
      </span>
      <span class="site-pv" title="总访问量">
        <span id="busuanzi_value_site_pv"></span>
      </span>
    </span>
</div>








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/pisces.js"></script>


<script src="/js/next-boot.js"></script>




  




  
<script src="/js/local-search.js"></script>













  

  

  
    <script type="text/javascript" color="0,0,0" opacity='0.5' zIndex="-2" count="200" src="/js/my_js/canvas-nest.min.js"></script>
    

</body>
<!-- 页面点击小红心 -->
<script type="text/javascript" src="/js/my_js/clicklove.js"></script>

<!-- calendar widget -->

    <script src="/lib/calendar/calendar.min.js"></script>
    <script src="/lib/calendar/languages.min.js"></script>
    <script type="text/javascript">
    $(function() {
        $('#CloudCalendar').aCalendar('zh-CN',
            $.extend(
                '', {
                    single:true,
                    root:'/calendar/'
                }
            )
        );
    });
    </script>


</html>
